<template>
  <div class="division">
    <list class="list" v-show="visible">
      <cell class="listItem" v-for="(item, index) in longList" :key="index" @click="addClassFun(item)" :class="[adcd === item.XZQHDM ? 'active' : '']">
          <text class="text" :class="[adcd === item.XZQHDM ? 'active' : '']">{{item.XZQHMC}}</text>
      </cell>
    </list>
  </div>
</template>
<script>
import event from '@/net/event.js'
import store from '@/store/ledgerHome'

export default {
  name: 'division',
  data () {
    return {
      longList:[]
    }
  },
  created () {
    event.XZQH(this.userAdcd).then(res => {
      let arr = res.result.datalist
      arr.unshift({
        XZQHMC: '全部',
        XZQHDM: this.userAdcd
      })
      this.longList = arr
    })
  },
  methods: {
    addClassFun (item) {
      store.commit('changeAdcd', item.XZQHDM)
      store.dispatch('getLedger', this)
      this.$emit('closeList')
    }
  },
  computed: {
    userAdcd () {
      return store.state.userAdcd
    },
    adcd () {
      return store.state.adcd
    }
  }
}
</script>
<style scoped>
.division{
  width: 750px;
  background-color: #fff;
  flex: 1;
}
.list{
  width: 750px;
}
.listItem{
  width: 750px;
  height: 100px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-left: 20px; 
  border-bottom-color: #f5f5f5;
  border-bottom-style: solid;
  border-bottom-width: 1px;
}
.text{
  font-size: 29.1px;
  font-family:PingFangSC-Regular;
  color:rgba(102,102,102,1);
}
.active{
  color: #fff;
  background-color: rgba(62,175,252,1);
}
</style>

